<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>身体质量指数测试</h1>
<form action="">
    <input type="text" name="h" placeholder="身高（米）">
    <input type="text" name="w" placeholder="体重（公斤）">
    <input type="button" value="开始测试" onclick="fn()">
</form>
<h2>测试结果：</h2>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    function fn() {
        //得到form表单中的数据
        let data =new FormData(document.querySelector("form"));
        //发出异步请求，post请求
        axios.post("/bmi",data).then(function (response) {
            //得到h2标签
            let h2 =document.querySelector("h2");
            //把服务器返回的数据 显示到h2中
            h2.innerText="测试结果："+response.data;
        })

    }
</script>

</body>
</html>